package xiangya.bysj.client.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import xiangya.bysj.entity.TakeCycle;
import xiangya.bysj.service.impl.TakeInfoServiceImpl;
import xiangya.bysj.util.JsonUtil;
import xiangya.bysj.util.StringUtil;

@Controller
@RequestMapping(value = "/client/takecycle", produces = "application/json;charset=UTF-8")
public class TakeCycleClientController {
	@Resource(name = "takeInfoService")
	private TakeInfoServiceImpl takeInfoService;

	@RequestMapping("/query")
	@ResponseBody
	public String query(int takeinfoId) {
		String result = StringUtil.RES_FAIL;
		try {
			List<TakeCycle> list = takeInfoService.getCycleByTakeInfoId(takeinfoId);
			result = JsonUtil.getJson(list);
		} catch (Exception e) {
			e.printStackTrace();
			result = StringUtil.RES_FAIL;
		}
		return result;
	}
}
